function Jumppages(selector){
	this.ele = $(selector).get(0);
	$(this.ele).find('li').on({
		'click':function(){
			this.index=$(this).index();
			if(this.index==0){
				window.open("landingpage.html");
			}else if(this.index==1){
				window.open("registerpage.html");
			}else if(this.index==3){
				window.open("shopcat.html");
			}	
		}
	})
	
}
function Carousel(selector) {
	this.ele = $(selector).get(0);
	this.index = 1;
	//console.log($(this.ele).find('.list img').width())
	this.btnAction();
	this.Mouseevent();
	this.buttonAction()
	this.timer = setInterval(this.moveAction.bind(this), 1000);
}
Carousel.prototype.btnAction = function() { //左右按钮

	var onself = this;

	$(onself.ele).find('.btn').click(function() {

		this.id == 'left' ? --onself.index : ++onself.index;
		onself.change();
	})
}
Carousel.prototype.Mouseevent = function() {
	var onself = this;

	$(onself.ele).on({
		'mouseenter': function() {
			clearInterval(onself.timer);
			$('.btn').toggle();
			//console.log(1)
		},
		'mouseleave': function() {
			onself.timer = setInterval(onself.moveAction.bind(onself), 3000);
			$('.btn').toggle();
		},
	})

}
Carousel.prototype.moveAction = function() { //自动轮播
	var onself = this;
	onself.index++;
	onself.change();
}
Carousel.prototype.buttonAction = function() {
	var onself = this;
	$(onself.ele).find('.button li').click(function() {
		onself.index = $(this).index() + 1;
		onself.change();
	})
}

Carousel.prototype.change = function() {
		var onself = this;
		var length = $(onself.ele).find('.list').children('li').size();
		if(onself.index <= 0) {
			$(onself.ele).find('.list').css('left', -$(onself.ele).find('.list img').width() * (length - 1))
			onself.index = length - 2;

		} else if(onself.index > length - 2) {

			$(onself.ele).find('.list').css('left', 0)
			onself.index = 1;
		}
		$(onself.ele).find('.list').stop().animate({
			'left': -$(onself.ele).find('.list li').width() * onself.index
		}, 200)
		$(onself.ele).find('.button li').eq(onself.index - 1).addClass('select').siblings().removeClass();
	}
	///
	////////////////////////爬梯
function Scrolltop(selector) {
	this.ele = $(selector).get(0);
	this.up = $('.showup').get(0);
	this.mouseaction();
}
Scrolltop.prototype.mouseaction = function() {
		Onself = this;
		var length = $(Onself.up).find('li').size();
		$(Onself.up).find(' li').on({
			'mouseenter mouseleave ': function() {

				this.index = $(this).index();
				if(this.index == 1) {
					$('.show').toggle();
				} 
			},

			'click': function() {

				Onself = this;
				//console.log(onself.index)			
				 if(Onself.index == length - 1) {
					$(window).scrollTop(0)
				}else if(Onself.index ==length - 2){
					window.open("shopcat.html");
				}

			}
		})
		$(window).scroll(function() {
//				console.log($(onself.ele))
			if($('html body').scrollTop() >500) {
//				
				$(Onself.ele).css({'left':$(window).width()-60,'display':'block'})
				
			}else{
				$(Onself.ele).css('display','none')
			}
		})
	}
	//、、、、、、、、、、、、、////////////切换
function Change(selector) {
	this.ele = $(selector).get(0);
	this.titleBtn();
}
Change.prototype.titleBtn = function() {
	var onself=this;
	$(onself.ele).find('.button_list li').click(function() {
		this.index = $(this).index();
		$('.button_list').find(' li ').eq(this.index).addClass('main_select').siblings().removeClass();
		if(this.index == 0) {
			//console.log(1)
			$('.main_new,.main_price ').css('display', 'none');
			$('.arrangement').css('display', 'block');
		} else if(this.index == 1) {
			$('.arrangement,.main_price').css('display', 'none');
			$('.main_new').css('display', 'block');
		} else if(this.index == 2) {
			$('.main_new,.arrangement').css('display', 'none');
			$('.main_price').css('display', 'block');
		}		
	})
	$('.skipnode').click(function(){
		window.open("detailspage.html");
		
	})
}

function Btnbg(selector){
	this.ele = $(selector).get(0);
	this.bgchang()
	
}
Btnbg.prototype.bgchang=function(){
	var _onself=this;
	this.index = $(this).index()+2;
	$(_onself.ele).find('li').click(function(){
		this.index=$(this).index();
		$(_onself.ele).find(' li a').removeClass();
		$(_onself.ele).find(' li a').eq(this.index).addClass('main_select1');
	})
}

function BtnselectNode(selector){
	this.ele = $(selector).get(0);
	this.skipnode();
}
BtnselectNode.prototype.skipnode=function(){
	$(this.ele).click(function(){
		window.open("detailspage.html");
		
	})
}
